package com.archives.blog.web.www;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.archives.blog.web.BaseSupportController;

@Controller
public class IndexController extends BaseSupportController{
	
	
	/**
	 * 路由入口
	 * 
	 * @returns
	 */
	@RequestMapping(value = {"/{templateName}", "/", ""})
	String routers(HttpServletRequest request, ModelMap model, @PathVariable(required = false) String templateName){
		try {
			router(model, templateName);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (request.getParameterMap() != null && request.getParameterMap().size() > 0) {
			model.addAttribute("req", request.getParameterMap());
		}
		return "/www/main";
	}

	
	/**
	 * 路由入口
	 * 
	 * @returns
	 */
	//@RequestMapping("/{templateName}/detail/{id}")
	String article(ModelMap model, @PathVariable String templateName, @PathVariable String id){
		router(model, templateName);
		return "/www/main";
	}
	
}
